@extends('layouts.app')

@section('content')
<div class="form-all mg_t30 main-content">
    <div id="faren">
        <a class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add_fxdpg()">新增</a>
        <a class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="edit_fxdpg()">编辑</a>
        <a class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="del_fxdpg()">删除</a>
    </div>
    <table id="fxdpg_form" title="风险度评价" class="easyui-datagrid" style="width:100%;height:720px;"
           data-options="rownumbers:true,singleSelect:true,pagination:true,pageSize:20,url:'http://nb.yntosite.com/json/fxdpg.json',method:'get',toolbar:'#faren'">
        <thead>
        <tr>
            <th data-options="field:'city'" width="10%" align="center">市</th>
            <th data-options="field:'area'" width="10%" align="center">区</th>
            <th data-options="field:'org_id'" width="10%" align="center">所属派出所</th>
            <th data-options="field:'type'" width="10%" align="center">企业类型</th>
            <th data-options="field:'name'" width="20%" align="center">单位名</th>
            <th data-options="field:'address'" width="30%" align="center">详细地址</th>
            <th data-options="field:'fxd_number'" width="10%" align="center">风险度评价</th>
        </tr>
        </thead>
    </table>
</div>
    <div id="tk" class="easyui-window" closed="true" title="新增" data-options="iconCls:'icon-save'"></div>

    <div id="del_faren" class="easyui-dialog" title="注销" closed="true" style="width:400px;height:200px;line-height:100px;text-align:center;font-size:16px;padding:10px">
        您确定要删除该记录？
    </div>
	<script type="text/javascript" src="{{ URL::asset('/') }}js/weizhi.js"></script>
    <script type="text/javascript">
        function add_fxdpg(){
        	var shuz = fb2();
            $('#tk').window({
                title: "添加",
                href: "add_fxdpg",
                width:shuz[0],
				height:shuz[1],
				top:shuz[2],
				left:shuz[3],
                minimizable:false,
                modal:true,
                closed: false,
            });
        }
        function edit_fxdpg(){
        	var shuz = fb2();
            var row = $('#fxdpg_form').datagrid('getSelected');
            if (row) {
                var url = "edit_fxdpg";
                $('#tk').window({
                    title: "编辑",
                    href: url,
                    width:shuz[0],
					height:shuz[1],
					top:shuz[2],
					left:shuz[3],
                    minimizable:false,
                    modal:true,
                    closed: false,
                });
            } else {
                $.messager.alert('提示','请选中要编辑的行！');
            }
        }
        function del_fxdpg(){
            var row = $('#fxdpg_form').datagrid('getSelected');
            if (row) {
                $('#del_faren').dialog({
                    title: "删除",
                    closed: false,
                    top:($(window).height() - 200) * 0.5,
				    left:($(window).width() - 400) * 0.5,
                    modal:true,
                    buttons: [{
                        text: '确定',
                        iconCls: 'icon-ok',
                        handler: del
                    }, {
                        text: '取消',
                        iconCls: 'icon-cancel',
                        handler: function () {
                            $('#del_faren').dialog('close');
                        }
                    }]
                });
            } else {
                $.messager.alert('提示','请选中要编辑的行！');
            }
        }

        function del(){
            $('#del_faren').dialog('close');
            var row = $('#fxdpg_form').datagrid('getSelected');
            var url = '/admin/yanpan/del_fxdpg/'+row.id;
            $.ajax({
                type: 'get',
                url: url,
                success: function(data){
                    if(data.status == 1){
                        $.messager.alert('信息提示',data.msg,'info');
                        var rowIndex = $('#faren_form').datagrid('getRowIndex', row);
                        $('#faren_form').datagrid('deleteRow', rowIndex);
                    }
                    else{
                        $.messager.alert('信息提示',data.msg,'info');
                    }
                }
            });
        }
        $("#fxdpg_form").datagrid({
            onDblClickRow: function (index, row) {
                edit_faren();
            }
        });
    </script>
<script>
    $(document).ready(function(){
        var winHeight =  window.screen.height;
        var winWidth = 	window.screen.width;
        if(winWidth == 1024){
            $('#taby').css('height',465+'px');
            $('#taby').find('iframe').css('height',436+'px');
        }else if(winWidth == 1280){
            $('#taby').css('height',465+'px');
            $('#taby').find('iframe').css('height',436+'px');
        }else if(winWidth == 1366){
            $('#taby').css('height',465+'px'); $('#taby').find('iframe').css('min-height',436+'px');
        }else if(winWidth == 1920){
            $('#taby').css('height',625+'px');
            $('#taby').find('iframe').css('min-height',596+'px');
        }else{
            $('#taby').css('height',465+'px');
            $('#taby').find('iframe').css('min-height',436+'px');
        }
    })

    function load_city_data_from_menu($id){
        $('#dg').datagrid('load',{
            city: $id,
        });
        $("input[name='city']").val($id);
        $("input[name='area']").val('');
        $("input[name='org_id']").val('');
    }

    function load_area_data_from_menu($id){
        $('#dg').datagrid('load',{
            area: $id,
        });
        $("input[name='city']").val('');
        $("input[name='area']").val($id);
        $("input[name='org_id']").val('');
    }
    function load_org_data_from_menu($id){
        $('#dg').datagrid('load',{
            org_id: $id,
        });
        $("input[name='city']").val('');
        $("input[name='area']").val('');
        $("input[name='org_id']").val($id);
    }
</script>
@stop

